package com.bdqn.t382;

import com.bdqn.t382.practice3.Paper;
import com.bdqn.t382.practice3.Printer;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class PrinterTest2 {
    @Test
    public void testPrinters() {
        // 加载 Spring 容器
        ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext1.xml");

        // 获取彩色打印机
        Printer colorPrinter = context.getBean("colorPrinter", Printer.class);
        colorPrinter.setPaper(context.getBean("a4Paper", Paper.class));
        colorPrinter.print("这是测试打印数据...........");

        // 获取黑白打印机
        Printer blackPrinter = context.getBean("blackPrinter", Printer.class);
        blackPrinter.setPaper(context.getBean("a4Paper", Paper.class));
        blackPrinter.print("这也是测试打印数据");
    }
}
